package sisicotren.ui.windows;

import java.io.File;
import java.io.IOException;

public class FileSystemView extends javax.swing.filechooser.FileSystemView {

	public FileSystemView(File topDir) {
		this.topDir = topDir;
	}
	
	public File getParentDirectory(File dir) {
		if(dir.getAbsoluteFile().equals(this.topDir.getAbsoluteFile()))
			return dir;
		
		return super.getParentDirectory(dir);
	}
	
	public File getHomeDirectory() {
		return this.topDir;
	}
	
	
	
	@Override
	public File createNewFolder(File containingDir) throws IOException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean isRoot(File f) {
		if(f.getAbsoluteFile().equals(this.topDir.getAbsoluteFile()))
			return true;
		// TODO Auto-generated method stub
		return super.isRoot(f);
	}

	@Override
	public boolean isFileSystemRoot(File dir) {
		if(dir.getAbsoluteFile().equals(this.topDir.getAbsoluteFile()))
			return true;
		// TODO Auto-generated method stub
		return super.isFileSystemRoot(dir);
	}

	@Override
	public File[] getRoots() {
		File [] roots = new File[1];
		roots[0] = new File(this.topDir.getAbsolutePath());
		return roots;
	}
	
	private File topDir;
}
